package com.winsomely.leecode;

import java.util.ArrayDeque;
import java.util.Deque;

/**
 * 
 * @author liujiawei
 *
 */
public class MinStack {
	Deque<Integer> dataDeque = new ArrayDeque<>();
	Deque<Integer> miniDeque = new ArrayDeque<>();

	public MinStack() {
		miniDeque.push(Integer.MAX_VALUE);
	}

	public void push(int x) {
		dataDeque.push(x);
		miniDeque.push(Math.min(miniDeque.peek(), x));
	}

	public void pop() {
		dataDeque.pop();
		miniDeque.pop();
	}

	public int top() {
		return dataDeque.peek();
	}

	public int getMin() {
		return miniDeque.peek();
	}

	public static void main(String[] args) {
		MinStack t = new MinStack();
		for (int i = 0; i < 10; i++) {
			t.push(i + 20);
		}
		System.out.println(t.getMin());
	}

}
